﻿using System;
using fastCSharp;

namespace diantou.web.onlineJudge
{
    /// <summary>
    /// 用户关注的问题列表
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPool = true, IsReferer = false)]
    partial class focusProblem : web.user.view<focusProblem>
    {
        /// <summary>
        /// 用户AC问题数量
        /// </summary>
        private int acceptedCount;
        /// <summary>
        /// 问题分数总和
        /// </summary>
        private int sumPoint;
        /// <summary>
        /// 用户AC问题分数总和
        /// </summary>
        private int acceptedPoint;
        /// <summary>
        /// 问题列表
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private userProblem[] problems;
        /// <summary>
        /// 分组菜单
        /// </summary>
        private groupMenu groupMenu
        {
            get { return new groupMenu { ViewOnly = requestHeader.IsReView }; }
        }

        /// <summary>
        /// 初始化问题列表
        /// </summary>
        /// <param name="userId">用户标识</param>
        /// <param name="page">分页号</param>
        /// <param name="sort">排序类型</param>
        /// <param name="isAsc">是否升序</param>
        /// <returns>是否成功</returns>
        private bool loadView(int userId, int page, diantou.dataAccess.problem.focusSort sort, bool isAsc)
        {
            if (base.load(userId, diantou.dataModel.path.pub.Default.OnlineJudgeAllProblemPath))
            {
                this.problems = diantou.dataAccess.clientCache.Problem.Get(diantou.dataAccess.tcpCall.problem.getFocusIds(userId, sort, isAsc, pageInfo.Size = 20, pageInfo.Page = page, out pageInfo.Count, out acceptedCount, out sumPoint, out acceptedPoint))
                    .getArray(value => new userProblem { Problem = value, User = currentUser });
                if (requestHeader.IsSearchEngine) pageInfo.Path = user.Path.OnlineJudgeFocusProblem.ToPageString();
                return true;
            }
            return false;
        }
    }
}
